package com.rogan.rpc.server;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;

import com.rogan.rpc.message.JSONMessageProtocol;

public class LocalConfigServiceInfoDiscoverer implements ServiceInfoDiscoverer{

	@Override
	public ServiceInfo getServiceInfo(String name) {
		ServiceInfo serverInfo = new ServiceInfo();
		List<String> addressList = new ArrayList<String>();
		InetAddress addr;
		try {
			addr = InetAddress.getLocalHost();
			addressList.add(addr.getLoopbackAddress().toString());
			serverInfo.setAddress(addressList);
			serverInfo.setName(addr.getHostName());
			serverInfo.setProtocol(JSONMessageProtocol.class.getSimpleName());
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		return serverInfo; 
		
	}

}
